package com.engine.common.baseEntity.jsonResponse;

import com.alibaba.fastjson.serializer.JSONSerializable;
import com.alibaba.fastjson.serializer.JSONSerializer;

import java.io.IOException;
import java.lang.reflect.Type;

public enum  StatusCode implements JSONSerializable {
    成功(0),
    系统异常(1000),
    服务器异常(1200),权限错误(1201),参数格式错误(1202),参数内容错误(1203),
    参数超出范围限制(1204),请求的数据表不存在(1205);

    private Integer code;

    StatusCode(Integer code) {
        this.code=code;
    }

    public static StatusCode getCodeStr(Integer code)
    {
        for(StatusCode statusCode : values())
        {
            if(statusCode.code==code)
                return statusCode;
        }
        return null;
    }

    public Integer getCode()
    {
        return this.code;
    }



    @Override
    public void write(JSONSerializer jsonSerializer, Object o, Type type, int i) throws IOException {
        jsonSerializer.write(this.getCode());
    }
}
